//ACV_init_main_dlg.sqf
//#define __ACV_Trace

#include "ACV_constantes.h"
#include "ACV_ID_main_dlg.h"
#include "ACV_ID_wp_dlg.h"
private ["_display","_cb_camp","_cb_faction","_cb_type","_cb_unit","_sl_skill","_sl_dir",
"_cb_empty","_cb_envol","_cb_type_grp","_cb_group","_cb_type_obj","_cb_obj","_cb_list_players",
"_btn_showallmarkers","_btn_showia","_btn_showplayer","_map","_btn_move_auto","_btn_script","_ctn_veh","_ctn_stock","_list_functions","_script_help","_btn_teleport"];
disableserialization;
_display = uiNamespace getVariable "R3F_ACV_MAIN_DLG";
_cb_camp = _display displayCtrl ACV_DLG_ID_Main_CbCamp;
_cb_faction = _display displayCtrl ACV_DLG_ID_Main_CbFaction;
_cb_type = _display displayCtrl ACV_DLG_ID_Main_CbType;
_cb_unit = _display displayCtrl ACV_DLG_ID_Main_CbUnit;
_sl_skill = _display displayCtrl ACV_DLG_ID_Main_SliderSkill;
_sl_dir = _display displayCtrl ACV_DLG_ID_Main_SliderDir;
_cb_empty = _display displayCtrl ACV_DLG_ID_Main_ChkEmpty;
_cb_envol = _display displayCtrl ACV_DLG_ID_Main_EnVol;
_cb_type_grp = _display displayCtrl ACV_DLG_ID_Main_GrpCbTypeUnit;
_cb_group = _display displayCtrl ACV_DLG_ID_Main_GrpCbUnit;
_cb_type_obj = _display displayCtrl ACV_DLG_ID_Main_CbObjtype;
_cb_obj = _display displayCtrl ACV_DLG_ID_Main_CbObj;
_cb_list_players = _display displayCtrl ACV_DLG_ID_Main_CbListPlayers;
_btn_showallmarkers = _display displayCtrl ACV_DLG_ID_Main_CbShowAll;
_btn_showia = _display displayCtrl ACV_DLG_ID_Main_CbShowIA;
_btn_showplayer = _display displayCtrl ACV_DLG_ID_Main_CbShowPlayer;
_map = _display displayCtrl ACV_DLG_ID_Main_Map;
_btn_move_auto = _display displayCtrl ACV_DLG_ID_Main_BtnMoveAuto;
_btn_script = _display displayCtrl ACV_DLG_ID_Main_BtnScript;
_ctn_veh = _display displayCtrl ACV_DLG_ID_CtnVehObj;
_ctn_stock = _display displayCtrl ACV_DLG_ID_CtnStock;
_list_functions = _display displayCtrl ACV_DLG_ID_Script_List;
_script_help = _display displayCtrl ACV_DLG_ID_Script_Help;
_btn_teleport = _display displayCtrl ACV_DLG_ID_Main_BtnTeleport;
ACV_FNCT_Fill_Functions_Categories = {
	private ["_entry","_nb","_i","_index","_hdr","_fnc","_str"];
	// TYRGHEN
	_entry = (missionConfigFile >> "cfgFunctions");
	_nb = count _entry;
	_str = "";
	_hdr = [];
	lbClear ACV_DLG_ID_Script_Categories;
	_fnc = {
		private ["_l","_j","_index","_group"];
		_group = (missionConfigFile >> "cfgFunctions" >> _this);
		_l = count _group;
		for [{_j = 0}, {_j < _l}, {_j = _j + 1}] do {
			if (isClass((_group) select _j)) then {
				// diag_log ["ACV","ACV_FNCT_Fill_Functions_Categories - adding",configName(_group select _j),_j,_this];
				_index = lbAdd [ACV_DLG_ID_Script_Categories, configName (_group select _j)];
				// Used to find the path in the config
				lbSetData [ACV_DLG_ID_Script_Categories, _index, _this];
				// The index inside the actual config
				lbSetValue [ACV_DLG_ID_Script_Categories, _index, _j];
			};
		};
	};
	for [{_i = 0}, {_i < _nb}, {_i = _i + 1}] do {
		// We extract the first 7 characters (or less if less)
		if (isClass((_entry) select _i)) then {
			_hdr = toArray(configName (_entry select _i));
			_hdr resize (7 min (count _hdr));
			_str = toUpper(toString(_hdr));
			// diag_log ["ACV","ACV_FNCT_Fill_Functions_Categories - STR",configName(_entry select _i),_str];
			if (_str == "R3F_ACV") then {
				(configName (_entry select _i)) call _fnc;
			};
		};
	};
	
	
	// _entry = (missionConfigFile >> "cfgFunctions" >> "R3F_ACV_LIB");
	// _nb = count _entry;
	// lbClear ACV_DLG_ID_Script_Categories;
	// for [{_i = 0}, {_i < _nb}, {_i = _i + 1}] do {
		// _index = lbAdd [ACV_DLG_ID_Script_Categories, configName (_entry select _i)];
		// lbSetData [ACV_DLG_ID_Script_Categories, _index, "R3F_ACV_LIB"];
	// };
	// _entry = (missionConfigFile >> "cfgFunctions" >> "R3F_ACV_EXTERNAL");
	// _nb = count _entry;
	// //diag_log ["ACV","ACV_FNCT_Fill_Functions_Categories",_nb];
	// for [{_i = 0}, {_i < _nb}, {_i = _i + 1}] do {
		// if (isClass((_entry) select _i)) then {
			// _index = lbAdd [ACV_DLG_ID_Script_Categories, configName ((_entry) select _i)];
			// //diag_log ["ACV","ACV_FNCT_Fill_Functions_Categories",_index,configName ((_entry) select _i)];
			// lbSetData [ACV_DLG_ID_Script_Categories, _index, configName ((_entry) select _i)];
		// };
	// };
	lbSetCurSel [ACV_DLG_ID_Script_Categories, (ACV_Default_Script_category min (lbSize ACV_DLG_ID_Script_Categories))];
};
ACV_FNCT_Fill_Functions = {
	private ["_entry","_nb","_i","_index"];
	_category_grp = lbData[ACV_DLG_ID_Script_Categories, ACV_Default_Script_category_index];
	// diag_log ["ACV","ACV_FNCT_Fill_Functions",ACV_Default_Script_category, _category_grp];
	_entry = (missionConfigFile >> "cfgFunctions" >> _category_grp) select ACV_Default_Script_category;
	_nb = count _entry;
	// diag_log ["ACV","ACV_FNCT_Fill_Functions",ACV_Default_Script_category, _category_grp, _nb];
	lbClear ACV_DLG_ID_Script_List;
	for [{_i = 0}, {_i < _nb}, {_i = _i + 1}] do {
		if (isClass((_entry) select _i)) then {
			// diag_log ["ACV","ACV_FNCT_Fill_Functions - FNC",_category_grp,ACV_Default_Script_category, configName ((_entry) select _i),_i];
			_index = lbAdd [ACV_DLG_ID_Script_List, configName ((_entry) select _i)];
			lbSetData [ACV_DLG_ID_Script_List, _index, _category_grp];
			lbSetValue [ACV_DLG_ID_Script_List, _index, _i];			
		};
	};
	lbSetCurSel [ACV_DLG_ID_Script_List, (ACV_Default_Script_function min (lbSize ACV_DLG_ID_Script_List))];
};
ACV_FNCT_Fill_Script_Help = {
	private ["_display","_list_functions","_entry","_description","_filename","_fnct_grp","_cnt","_nb","_i","_parent_file"];
	disableserialization;
	_display = uiNamespace getVariable "R3F_ACV_MAIN_DLG";
	_list_functions = _display displayCtrl ACV_DLG_ID_Script_List;
	_fnct_grp = lbData [ACV_DLG_ID_Script_Categories,ACV_Default_Script_category_index];
	// diag_log ["ACV","ACV_FNCT_Fill_Script_Help",ACV_Default_Script_category, _fnct_grp,ACV_Default_Script_function];
	//TYRGHEN - The following didn't take into account the new structure of function files
	_cnt = -1;
	_entry = (missionConfigFile >> "cfgFunctions"  >> _fnct_grp) select ACV_Default_Script_category;
	_nb = count ((missionConfigFile >> "cfgFunctions"  >> _fnct_grp) select ACV_Default_Script_category);
	_parent_file = "";
	if (isText(_entry >> "file")) then { _parent_file = gettext (_entry >> "file"); };
	// diag_log ["ACV","ACV_FNCT_Fill_Script_Help",ACV_Default_Script_category, configName(_entry), _parent_file];
	_entry = (_entry select ACV_Default_Script_function);
	// diag_log ["ACV","ACV_FNCT_Fill_Script_Help - Found",ACV_Default_Script_category, configName(_entry)];
	//_entry = (missionConfigFile >> "cfgFunctions"  >> _fnct_grp) select ACV_Default_Script_category;
	//_entry = _entry select ACV_Default_Script_function;
	_description = "";
	if (isText(_entry >> "description")) then {	_description = gettext (_entry >> "description"); };
	_filename = "";
	if (isText(_entry >> "file")) then { _filename = gettext (_entry >> "file"); };
	// diag_log ["ACV","ACV_FNCT_Fill_Script_Help - file",ACV_Default_Script_category,_filename,_parent_file];
	if (_filename ==  "" || _filename == _parent_file) then {
		_filename = _parent_file + "\fn_" + configName(_entry) + ".sqf";
	};
	// diag_log ["ACV","ACV_FNCT_Fill_Script_Help - end",ACV_Default_Script_category, _description, _filename];
	ctrlSetText [ACV_DLG_ID_Script_Help, (loadfile _filename)];
	_list_functions ctrlSetTooltip _description;
};
ACV_FNCT_ShowScript = {
	private ["_display","_btn_script","_ctn_veh","_ctn_stock","_x"];
	disableserialization;
	_display = uiNamespace getVariable "R3F_ACV_MAIN_DLG";
	_btn_script = _display displayCtrl ACV_DLG_ID_Main_BtnScript;
	_ctn_veh = _display displayCtrl ACV_DLG_ID_CtnVehObj;
	_ctn_stock = _display displayCtrl ACV_DLG_ID_CtnStock;
	{	ctrlShow [_x,false];
	} foreach ACV_ctrl_for_units;
	{	ctrlShow [_x,true];
	} foreach ACV_ctrl_for_scripts;
	ctrlSetText [ACV_DLG_ID_Main_BtnScript, localize "STR_ACV_LABEL_UNITS"];
	ctrlSetText [ACV_DLG_ID_Main_LabelVehVide, localize "STR_ACV_BTN_SCRIPT"];
	ctrlSetText [ACV_DLG_ID_Main_LegendWp, localize "STR_TOOLTIP_SCRIPTEDITOR"];
	_ctn_veh ctrlSetBackgroundColor [0, 0, 0, 0.84];
	_ctn_stock ctrlSetBackgroundColor [0, 0, 0, 0.84];
	_btn_script ctrlSetTooltip localize "STR_TOOLTIP_MANAGESUNITSGROUP";
};
ACV_FNCT_HideScript = {
	private ["_display","_btn_script","_ctn_veh","_ctn_stock","_x"];
	disableserialization;
	_display = uiNamespace getVariable "R3F_ACV_MAIN_DLG";
	_btn_script = _display displayCtrl ACV_DLG_ID_Main_BtnScript;
	_ctn_veh = _display displayCtrl ACV_DLG_ID_CtnVehObj;
	_ctn_stock = _display displayCtrl ACV_DLG_ID_CtnStock;
	{	ctrlShow [_x,true];
	} foreach ACV_ctrl_for_units;
	{	ctrlShow [_x,false];
	} foreach ACV_ctrl_for_scripts;
	ctrlSetText [ACV_DLG_ID_Main_BtnScript, localize "STR_ACV_BTN_SCRIPT"];
	ctrlSetText [ACV_DLG_ID_Main_LabelVehVide, localize "STR_ACV_TITLE_OBJECTS"];
	ctrlSetText [ACV_DLG_ID_Main_LegendWp, localize "STR_ACV_LABEL_WAYPOINT"];
	_ctn_veh ctrlSetBackgroundColor [0.03, 0, 0, 0.63];
	_ctn_stock ctrlSetBackgroundColor [0.03, 0, 0, 0.63];
	_btn_script ctrlSetTooltip localize "STR_TOOLTIP_SCRIPTMAGEMENT";
};
ACV_FNCT_SliderDirChange = {
	private ["_display","_value","_label"];
	disableserialization;
	_value = _this select 0;
	_display = uiNamespace getVariable "R3F_ACV_MAIN_DLG";
	_label = _display displayCtrl ACV_DLG_ID_Main_LabelDir;
	_label ctrlSetText format["%1° :", round _value];
};
ACV_FNCT_FillCamp = {
	private ["_control","_idx"];
	_control = _this select 0;
	lbClear _control;
	{	_idx = _control lbAdd (_x select 2);
		__TRACE_2("ACV_FNCT_FillCamp",_idx, _x)
		_control lbSetData [_idx, _x select 1];
		_control lbSetValue [_idx, _x select 0];
	} foreach ACV_ARRAY_SIDE;
	_control lbSetCurSel ACV_Default_Side;
	__TRACE_2("ACV_FNCT_FillCamp",ACV_Default_Side,lbCurSel _control)
};
ACV_FNCT_FillFaction = {
	private ["_control","_idx_side","_id_side","_side","_idx","_x"];
	_control = _this select 0;
	_idx_side = ACV_Default_Side;
	_id_side = ACV_Sel_Side;
	lbClear _control;
	{	_side = _x select 0;
		__TRACE_2("ACV_FNCT_FillFaction",_id_side,_x)
		if ( _side == _id_side) then {
			__TRACE_2("ACV_FNCT_FillFaction Add",_id_side,_x)
			_idx = _control lbAdd (_x select 2);
			if ((_x select 1) == ACV_Sel_Faction) then { ACV_Default_Faction = _idx; };
			_control lbSetData [_idx,_x select 1];
			_control lbSetValue [_idx,_side];
		};
	} foreach ACV_ARRAY_FACTION;
	_control lbSetCurSel ACV_Default_Faction;
	ACV_Sel_Faction = _control lbData (lbCurSel _control);
};
ACV_FNCT_FillType = {
	private ["_control","_idx","_x"];
	_control = _this select 0;
	lbClear _control;
	{	_idx = _control lbAdd ( _x select 2 );
		__TRACE_2("ACV_FNCT_FillType",_x select 1,_x select 0)
		_control lbSetData [ _idx, _x select 1];
		_control lbSetValue [_idx, _x select 0];
	} foreach ACV_ARRAY_TYPE;
	_control lbSetCurSel ACV_Default_Type;
};
ACV_FNCT_FillUnit ={
	private ["_control","_arr","_sel_type","_faction","_x","_type"];
	_control = _this select 0;
	lbClear _control;
	_arr = switch (ACV_Default_Type) do {
		case 0: {ACV_ARRAY_CLASS_MAN};
		case 1: {ACV_ARRAY_CLASS_AIR};
		case 2: {ACV_ARRAY_CLASS_TANK};
		case 3: {ACV_ARRAY_CLASS_CAR};
		case 4: {ACV_ARRAY_CLASS_TRUCK};
		case 5: {ACV_ARRAY_CLASS_STATIC};
		case 6: {ACV_ARRAY_CLASS_SHIP};
	};
	_sel_type = switch (ACV_Default_Type) do {
		case 0: {"MAN"};
		case 1: {"AIR"};
		case 2: {"TANK"};
		case 3: {"CAR"};
		case 4: {"TRUCK"};
		case 5: {"STATIC"};
		case 6: {"SHIP"};
	};
	__TRACE_3("ACV_FNCT_FillUnit",_sel_type,ACV_Sel_Faction,_arr)
	{	_faction = _x select 1;
		__TRACE_3("ACV_FNCT_FillUnit",_x select 0,_x select 1,_x select 2)
		if (_faction == ACV_Sel_Faction) then{
			_type = _x select 2;
			if (_type == _sel_type) then{
				__TRACE_1("  >> Adding",_x)
				_idx = _control lbAdd (_x select 4 );
				_control lbSetData [_idx,_x select 2];
				_control lbSetValue [_idx,_x select 0];
			};
		};
	} foreach _arr;
	_control lbSetCurSel ACV_Default_Unit;
};
ACV_FNCT_FillTypeGrp = {
	private ["_control","_idx_side","_side","_faction","_idx","_x"];
	_control = _this select 0;
	_idx_side = ACV_Sel_Side;
	lbClear _control;
	__TRACE_2("ACV_FNCT_FillTypeGrp",ACV_Sel_Side,ACV_Sel_Faction)
	{	_side = _x select 0;
		_faction = _x select 1;
		__TRACE_1("ACV_FNCT_FillTypeGrp",_x)
		if ( _side == _idx_side) then {
			if (_faction == ACV_Sel_Faction) then {
				__TRACE_1("  >> Adding",_x)
				_idx = _control lbAdd (_x select 3 );
				_control lbSetData [_idx,_x select 2 ];
				_control lbSetValue [_idx,_side];
			};
		};
	} foreach ACV_ARRAY_GROUP;
	_control lbSetCurSel ACV_Default_TypeGrp;
};
ACV_FNCT_FillGroup = {
	private ["_control","_side","_faction","_type_group","_idx","_idx_side","_x"];
	_control = _this select 0;
	_idx_side = ACV_Sel_Side;
	lbClear _control;
	__TRACE_3("ACV_FNCT_FillGroup",ACV_Sel_Side,ACV_Sel_Faction,ACV_Sel_TypeGrp)
	{	_side = _x select 0;
		_faction = _x select 1;
		_type_group = _x select 2;
		__TRACE_1("ACV_FNCT_FillGroup",_x)
		if (_side == _idx_side) then {
			if (_faction == ACV_Sel_Faction) then {
				if (_type_group == ACV_Sel_TypeGrp) then {
					__TRACE_1("  >> Adding",_x)
					_idx = _control lbAdd (_x select 4);
					_control lbSetData [_idx,_x select 3];
					if (count _x > 5 && {(_x select 5)}) then {
						_control lbSetValue [_idx,1];
					} else {
						_control lbSetValue [_idx,0];
					};
				};
			};
		};
	} foreach ACV_ARRAY_GROUP_NAME;
	_control lbSetCurSel ACV_Default_Group;
};
ACV_FNCT_FillTypeObj = {
	private ["_control","_x"];
	_control = _this select 0;
	lbClear _control;
	// diag_log format ["ACV_FNCT_FillTypeObj: %1",[_this,ACV_Default_TypeObj,ACV_ARRAY_CLASS_ObjType]];
	{ call compile format["_idx = _control lbAdd ((%1 select 0) select 2)", _x];
	__TRACE_1("ACV_FNCT_FillTypeObj",_x)
	} foreach ACV_ARRAY_CLASS_ObjTypeDisplayed;
	_control lbSetCurSel ACV_Default_TypeObj;
};
ACV_FNCT_FillObj = {
	private["_control","_arr","_first","_idx","_x"];
	_control = _this select 0;
	call compile format["_arr = %1;", ACV_ARRAY_CLASS_ObjTypeDisplayed select ACV_Default_TypeObj];
	lbClear _control;
	_first = true;
	{	if (!_first) then {
			_idx = _control lbAdd (_x select 4);
			_control lbSetData [_idx, _x select 3];
		};
		__TRACE_1("ACV_FNCT_FillObj",_x)
		_first = false;
	} foreach _arr;
	_control lbSetCurSel ACV_Default_Obj;
};
ACV_FNCT_FillYesNo = {
	private ["_control","_x"];
	_control = _this select 0;
	lbClear _control;
	{	_control lbAdd (_x select 1);
	} foreach ACV_ARRAY_YESNO;
	_control lbSetCurSel (_this select 1);
};
ACV_FNCT_FillPlayer = {
	private ["_old_sel","_display","_x"];
	disableSerialization;
	_display = findDisplay ACV_DLG_ID_Main_Dlg;
	if (_display != displayNull) then {
		_old_sel = lbCurSel ACV_DLG_ID_Main_CbListPlayers;
		lbClear ACV_DLG_ID_Main_CbListPlayers;
		{	lbAdd [ACV_DLG_ID_Main_CbListPlayers,(name _x)];
		} foreach playableUnits;
		lbSetCurSel [ ACV_DLG_ID_Main_CbListPlayers,_old_sel];
	};
};
ACV_Filling_Dlg = true; // Pour bloquer les mise à jour des oncomboselect ou autre joyeusetés
if (ACV_Mode_Script) then {
	call ACV_FNCT_ShowScript;
} else {
	call ACV_FNCT_HideScript;
};
[_cb_camp] call ACV_FNCT_FillCamp;
[_cb_faction] call ACV_FNCT_FillFaction;
[_cb_type] call ACV_FNCT_FillType;
[_cb_unit] call ACV_FNCT_FillUnit;
[_cb_empty, ACV_Default_Empty] call ACV_FNCT_FillYesNo;
[_cb_envol, ACV_Default_EnVol] call ACV_FNCT_FillYesNo;
[_cb_type_grp] call ACV_FNCT_FillTypeGrp;
[_cb_group] call ACV_FNCT_FillGroup;
[_cb_type_obj] call ACV_FNCT_FillTypeObj;
[_cb_obj] call ACV_FNCT_FillObj;
_sl_skill sliderSetRange [1,10];
_sl_skill sliderSetPosition ACV_Default_Skill * 10;
ACV_Default_Dir = (direction player) * 10;
_sl_dir sliderSetRange [0,360];
_sl_dir sliderSetPosition (ACV_Default_Dir / 10);
[ACV_Default_Dir / 10] call ACV_FNCT_SliderDirChange;
[] call ACV_FNCT_RefreshListUnits;
[] call ACV_FNCT_RefreshListObjects;
[] call ACV_FNCT_Fill_Functions_Categories;
//Removed
//[] call ACV_FNCT_Fill_Functions_Folders;
[] call ACV_FNCT_Fill_Functions;
[] call ACV_FNCT_Fill_Script_Help;
ctrlSetText [ACV_DLG_ID_Script_Edit, ACV_Default_Script];
if (!ACV_Show_All_Markers) then {
	_btn_showallmarkers ctrlSetText localize "STR_ACV_BTN_LOOK";
	_btn_showallmarkers ctrlSetTooltip localize "STR_TOOLTIP_SHOWMARKERS";
} else {
	_btn_showallmarkers ctrlSetText "--";
	_btn_showallmarkers ctrlSetTooltip localize "STR_TOOLTIP_HIDEMARKERS";
};
if (!ACV_ShowIA) then {
	_btn_showia ctrlSetText localize "STR_ACV_BTN_LOOK_IA";
	_btn_showia ctrlSetTooltip localize "STR_TOOLTIP_SHOWIA";
} else {
	_btn_showia ctrlSetText "--";
	_btn_showia ctrlSetTooltip localize "STR_TOOLTIP_HIDEIA";
};
if (!ACV_ShowPlayer) then {
	_btn_showplayer ctrlSetText localize "STR_ACV_BTN_LOOK_PLAYER";
	_btn_showplayer ctrlSetTooltip localize "STR_TOOLTIP_SHOWPLAYER";
} else {
	_btn_showplayer ctrlSetText "--";
	_btn_showplayer ctrlSetTooltip localize "STR_TOOLTIP_HIDEPLAYER";
};
if (ACV_Move_Map_Auto) then {
	_btn_move_auto ctrlSetText localize "STR_TOOLTIP_NOMOVE";
	_btn_move_auto ctrlSetTooltip localize "STR_TOOLTIP_BLOCKMOVE";
} else {
	_btn_move_auto ctrlSetText localize "STR_ACV_BTN_MOVE_AUTO";
	_btn_move_auto ctrlSetTooltip localize "STR_TOOLTIP_ALLOWMOVE";
};
#ifdef __ACV_No_God_User
_btn_showia ctrlEnable false;
if (ACV_ShowIA) then {
	nul = [false] execVM "tmf\core\modules\r3f_acv\Scripts\show_ia.sqf";
};
_btn_teleport ctrlEnable false;
#endif
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_SliderSkill) ctrlSetTooltip localize "STR_TOOLTIP_IASKILL";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_ChkEmpty) ctrlSetTooltip localize "STR_TOOLTIP_EMPTYVEHICLE";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_EnVol) ctrlSetTooltip localize "STR_TOOLTIP_INFLY";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_BtnMakeUnit) ctrlSetTooltip localize "STR_TOOLTIP_MAKEVEHICLE";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_GrpCbTypeUnit) ctrlSetTooltip localize "STR_TOOLTIP_AIGROUP";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_BtnMakeGrp) ctrlSetTooltip localize "STR_TOOLTIP_CREATEGROUP";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_CbObjtype) ctrlSetTooltip localize "STR_TOOLTIP_LISTOBJECTS";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_MkObj) ctrlSetTooltip localize "STR_TOOLTIP_OBJECTSLIST";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_LstStock) ctrlSetTooltip localize "STR_TOOLTIP_UNITSGROUPLIST";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_BtnDeleteUnit) ctrlSetTooltip localize "STR_TOOLTIP_CLEARGROUP";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_ListObjects) ctrlSetTooltip localize "STR_TOOLTIP_LISTCREATEDOBJECT";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_DeleteObjects) ctrlSetTooltip localize "STR_TOOLTIP_DELETEOBJECTSELECTED";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_ListWp) ctrlSetTooltip localize "STR_TOOLTIP_WAYPOINSLIST";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_AddWp) ctrlSetTooltip localize "STR_TOOLTIP_ADDWAYPOINT";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_EditWp) ctrlSetTooltip localize "STR_TOOLTIP_EDITWAYPOINT";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_DelWp) ctrlSetTooltip localize "STR_TOOLTIP_DELETEWAYPOINT";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_BtnCamera) ctrlSetTooltip localize "STR_TOOLTIP_INCAMERA";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Main_BtnTeleport) ctrlSetTooltip localize "STR_TOOLTIP_TELEPORT";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Script_Categories) ctrlSetTooltip localize "STR_TOOLTIP_SCRIPTSCATEGORIES";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Script_Folders) ctrlSetTooltip localize "STR_TOOLTIP_FUNCTIONTYPE";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Script_Help) ctrlSetTooltip localize "STR_TOOLTIP_FUNCTIONDOC";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Script_Edit) ctrlSetTooltip localize "STR_TOOLTIP_SCRIPTEDITOR";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Script_Run) ctrlSetTooltip localize "STR_TOOLTIP_SCRIPTRUN";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Script_Raz) ctrlSetTooltip localize "STR_TOOLTIP_SCRIPTRESET";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Script_Copy) ctrlSetTooltip localize "STR_TOOLTIP_SCRIPTCOPY";
((findDisplay ACV_DLG_ID_Main_Dlg) displayCtrl ACV_DLG_ID_Script_Replace) ctrlSetTooltip localize "STR_TOOLTIP_SCRIPTREPLACE";
[] call ACV_FNCT_FillPlayer;
sleep 0.03;
[] call ACV_FNCT_CancelMakeUnit;
_map ctrlmapanimadd [0.5,0.15,ACV_PosMapACV];
ctrlmapanimcommit _map;
sleep 1;//OBLIGATOIRE
ACV_Filling_Dlg = false;